package com.yuanhua.xcxmng.wechat.job;

import cn.hutool.cron.task.Task;
import com.yuanhua.xcxmng.wechat.entity.User;
import com.yuanhua.xcxmng.wechat.mapper.UserMapper;
import com.yuanhua.xcxmng.wechat.mapper.UserRunMapper;
import com.yuanhua.xcxmng.wechat.mapper.UserTargetMapper;
import com.yuanhua.xcxmng.wechat.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UpdateStepTask extends BaseTask implements Task {

    private static final long i = 0;

    @Autowired
    private UserMapper        userMapper;
    @Autowired
    private UserRunMapper     userRunMapper;
    @Autowired
    private UserTargetMapper  userTargetMapper;
    @Autowired
    private UserService       userService;

    @Override
    public void execute() {
        List<User> users = userMapper.findAllUser();
        for (User user : users) {
            user.setStep(i);
            try {
                userService.updateByPrimaryKey(user);
            } catch (Exception e) {
                logger.error(e,e.getMessage());
            }
        }
    }
}
